home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / tail2nos.c < prev    next >
C/C++ Source or Header  |  2000-04-10  |  12KB  |  371 lines

  1. /***************************************************************************
  2.  
  3. Tail to Nose / Super Formula - (c) 1989 Video System Co.
  4.  
  5. Driver by Nicola Salmoria
  6.  
  7.  
  8. press F1+F3 to see ROM/RAM tests and the final animation
  9.  
  10. ***************************************************************************/
  11.  
  12. #include "driver.h"
  13. #include "vidhrdw/generic.h"
  14. #include "vidhrdw/konamiic.h"
  15. #include "cpu/z80/z80.h"
  16.  
  17.  
  18. extern unsigned char *tail2nos_bgvideoram;
  19.  
  20. READ_HANDLER( tail2nos_bgvideoram_r );
  21. WRITE_HANDLER( tail2nos_bgvideoram_w );
  22. READ_HANDLER( tail2nos_zoomdata_r );
  23. WRITE_HANDLER( tail2nos_zoomdata_w );
  24. WRITE_HANDLER( tail2nos_gfxbank_w );
  25. int tail2nos_vh_start(void);
  26. void tail2nos_vh_stop(void);
  27. void tail2nos_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  28.  
  29.  
  30. static READ_HANDLER( pip )
  31. {
  32.     return rand()&0xffff;
  33. }
  34. static void tail2nos_init_machine(void)
  35. {
  36.     /* point to the extra ROMs */
  37.     cpu_setbank(1,memory_region(REGION_USER1));
  38.     cpu_setbank(2,memory_region(REGION_USER2));
  39.  
  40.     /* initialize sound bank */
  41.     cpu_setbank(9,memory_region(REGION_CPU2) + 0x10000);
  42. }
  43.  
  44.  
  45. static WRITE_HANDLER( sound_command_w )
  46. {
  47.     if ((data & 0x00ff0000) == 0)
  48.     {
  49.         soundlatch_w(offset,data & 0xff);
  50.         cpu_cause_interrupt(1,Z80_NMI_INT);
  51.     }
  52. }
  53.  
  54. static READ_HANDLER( tail2nos_K051316_0_r )
  55. {
  56.     return K051316_0_r(offset >> 1);
  57. }
  58.  
  59. static WRITE_HANDLER( tail2nos_K051316_0_w )
  60. {
  61.     if ((data & 0x00ff0000) == 0)
  62.         K051316_0_w(offset >> 1, data & 0xff);
  63. }
  64.  
  65. static WRITE_HANDLER( tail2nos_K051316_ctrl_0_w )
  66. {
  67.     if ((data & 0x00ff0000) == 0)
  68.         K051316_ctrl_0_w(offset >> 1, data & 0xff);
  69. }
  70.  
  71. static WRITE_HANDLER( sound_bankswitch_w )
  72. {
  73.     cpu_setbank(9,memory_region(REGION_CPU2) + 0x10000 + (data & 0x01) * 0x8000);
  74. }
  75.  
  76.  
  77.  
  78. static struct MemoryReadAddress readmem[] =
  79. {
  80.     { 0x000000, 0x03ffff, MRA_ROM },
  81.     { 0x200000, 0x27ffff, MRA_BANK1 },    /* extra ROM */
  82.     { 0x2c0000, 0x2dffff, MRA_BANK2 },    /* extra ROM */
  83.     { 0x400000, 0x41ffff, tail2nos_zoomdata_r },
  84.     { 0x500000, 0x500fff, tail2nos_K051316_0_r },
  85.     { 0xff8000, 0xffbfff, MRA_BANK3 },    /* work RAM */
  86.     { 0xffc000, 0xffc2ff, MRA_BANK4 },    /* sprites */
  87.     { 0xffc300, 0xffcfff, MRA_BANK5 },
  88.     { 0xffd000, 0xffdfff, tail2nos_bgvideoram_r },
  89.     { 0xffe000, 0xffefff, paletteram_word_r },
  90.     { 0xfff000, 0xfff001, input_port_0_r },
  91.     { 0xfff004, 0xfff005, input_port_1_r },
  92.     { -1 }  /* end of table */
  93. };
  94.  
  95. static struct MemoryWriteAddress writemem[] =
  96. {
  97.     { 0x000000, 0x03ffff, MWA_ROM },
  98.     { 0x200000, 0x27ffff, MWA_ROM },
  99.     { 0x2c0000, 0x2dffff, MWA_ROM },
  100.     { 0x400000, 0x41ffff, tail2nos_zoomdata_w },
  101.     { 0x500000, 0x500fff, tail2nos_K051316_0_w },
  102.     { 0x510000, 0x51001f, tail2nos_K051316_ctrl_0_w },
  103.     { 0xff8000, 0xffbfff, MWA_BANK3 },    /* work RAM */
  104.     { 0xffc000, 0xffc2ff, MWA_BANK4, &spriteram, &spriteram_size },
  105.     { 0xffc300, 0xffcfff, MWA_BANK5 },
  106.     { 0xffd000, 0xffdfff, tail2nos_bgvideoram_w, &tail2nos_bgvideoram },
  107.     { 0xffe000, 0xffefff, paletteram_xRRRRRGGGGGBBBBB_word_w, &paletteram },
  108.     { 0xfff000, 0xfff001, tail2nos_gfxbank_w },
  109.     { 0xfff008, 0xfff009, sound_command_w },
  110.     { -1 }  /* end of table */
  111. };
  112.  
  113. static struct MemoryReadAddress sound_readmem[] =
  114. {
  115.     { 0x0000, 0x77ff, MRA_ROM },
  116.     { 0x7800, 0x7fff, MRA_RAM },
  117.     { 0x8000, 0xffff, MRA_BANK9 },
  118.     { -1 }  /* end of table */
  119. };
  120.  
  121. static struct MemoryWriteAddress sound_writemem[] =
  122. {
  123.     { 0x0000, 0x77ff, MWA_ROM },
  124.     { 0x7800, 0x7fff, MWA_RAM },
  125.     { 0x8000, 0xffff, MWA_ROM },
  126.     { -1 }  /* end of table */
  127. };
  128.  
  129. static struct IOReadPort sound_readport[] =
  130. {
  131.     { 0x07, 0x07, soundlatch_r },
  132. #if 0
  133.     { 0x18, 0x18, YM2610_status_port_0_A_r },
  134.     { 0x1a, 0x1a, YM2610_status_port_0_B_r },
  135. #endif
  136.     { -1 }    /* end of table */
  137. };
  138.  
  139. static struct IOWritePort sound_writeport[] =
  140. {
  141.     { 0x07, 0x07, IOWP_NOP },    /* clear pending command */
  142.     { 0x08, 0x08, YM2608_control_port_0_A_w },
  143.     { 0x09, 0x09, YM2608_data_port_0_A_w },
  144.     { 0x0a, 0x0a, YM2608_control_port_0_B_w },
  145.     { 0x0b, 0x0b, YM2608_data_port_0_B_w },
  146.     { -1 }    /* end of table */
  147. };
  148.  
  149.  
  150.  
  151. INPUT_PORTS_START( tail2nos )
  152.     PORT_START
  153.     PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_UNKNOWN )
  154.     PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_UNKNOWN )
  155.     PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_2WAY )
  156.     PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_2WAY )
  157.     PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON2 )
  158.     PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON1 )
  159.     PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN )
  160.     PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN )
  161.     PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_COIN1 )
  162.     PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_COIN2 )
  163.     PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_START1 )
  164.     PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_START2 )
  165.     PORT_BITX(0x1000, IP_ACTIVE_LOW, IPT_SERVICE, "Test Advance", KEYCODE_F1, IP_JOY_DEFAULT )
  166.     PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_UNKNOWN )
  167.     PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_SERVICE1 )
  168.     PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
  169.  
  170.     PORT_START
  171.     PORT_DIPNAME( 0x000f, 0x0000, DEF_STR( Coin_A ) )
  172.     PORT_DIPSETTING(      0x0009, DEF_STR( 5C_1C ) )
  173.     PORT_DIPSETTING(      0x0008, DEF_STR( 4C_1C ) )
  174.     PORT_DIPSETTING(      0x0007, DEF_STR( 3C_1C ) )
  175.     PORT_DIPSETTING(      0x0006, DEF_STR( 2C_1C ) )
  176.     PORT_DIPSETTING(      0x000b, "6 Coins/4 Credits" )
  177.     PORT_DIPSETTING(      0x000c, DEF_STR( 4C_3C ) )
  178.     PORT_DIPSETTING(      0x0000, DEF_STR( 1C_1C ) )
  179.     PORT_DIPSETTING(      0x000d, "5 Coins/6 Credits" )
  180.     PORT_DIPSETTING(      0x000e, DEF_STR( 4C_5C ) )
  181.     PORT_DIPSETTING(      0x000a, DEF_STR( 2C_3C ) )
  182. //    PORT_DIPSETTING(      0x000f, DEF_STR( 2C_3C ) )
  183.     PORT_DIPSETTING(      0x0001, DEF_STR( 1C_2C ) )
  184.     PORT_DIPSETTING(      0x0002, DEF_STR( 1C_3C ) )
  185.     PORT_DIPSETTING(      0x0003, DEF_STR( 1C_4C ) )
  186.     PORT_DIPSETTING(      0x0004, DEF_STR( 1C_5C ) )
  187.     PORT_DIPSETTING(      0x0005, DEF_STR( 1C_6C ) )
  188.     PORT_DIPNAME( 0x00f0, 0x0000, DEF_STR( Coin_B ) )
  189.     PORT_DIPSETTING(      0x0090, DEF_STR( 5C_1C ) )
  190.     PORT_DIPSETTING(      0x0080, DEF_STR( 4C_1C ) )
  191.     PORT_DIPSETTING(      0x0070, DEF_STR( 3C_1C ) )
  192.     PORT_DIPSETTING(      0x0060, DEF_STR( 2C_1C ) )
  193.     PORT_DIPSETTING(      0x00b0, "6 Coins/4 Credits" )
  194.     PORT_DIPSETTING(      0x00c0, DEF_STR( 4C_3C ) )
  195.     PORT_DIPSETTING(      0x0000, DEF_STR( 1C_1C ) )
  196.     PORT_DIPSETTING(      0x00d0, "5 Coins/6 Credits" )
  197.     PORT_DIPSETTING(      0x00e0, DEF_STR( 4C_5C ) )
  198.     PORT_DIPSETTING(      0x00a0, DEF_STR( 2C_3C ) )
  199. //    PORT_DIPSETTING(      0x00f0, DEF_STR( 2C_3C ) )
  200.     PORT_DIPSETTING(      0x0010, DEF_STR( 1C_2C ) )
  201.     PORT_DIPSETTING(      0x0020, DEF_STR( 1C_3C ) )
  202.     PORT_DIPSETTING(      0x0030, DEF_STR( 1C_4C ) )
  203.     PORT_DIPSETTING(      0x0040, DEF_STR( 1C_5C ) )
  204.     PORT_DIPSETTING(      0x0050, DEF_STR( 1C_6C ) )
  205.     PORT_DIPNAME( 0x0300, 0x0000, DEF_STR( Difficulty ) )
  206.     PORT_DIPSETTING(      0x0100, "Easy" )
  207.     PORT_DIPSETTING(      0x0000, "Normal" )
  208.     PORT_DIPSETTING(      0x0200, "Hard" )
  209.     PORT_DIPSETTING(      0x0300, "Super" )
  210.     PORT_DIPNAME( 0x0400, 0x0000, DEF_STR( Demo_Sounds ) )
  211.     PORT_DIPSETTING(      0x0400, DEF_STR( Off ) )
  212.     PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
  213.     PORT_SERVICE( 0x0800, IP_ACTIVE_HIGH )
  214.     PORT_DIPNAME( 0x1000, 0x1000, "Game Mode" )
  215.     PORT_DIPSETTING(      0x1000, "Single" )
  216.     PORT_DIPSETTING(      0x0000, "Multiple" )
  217.     PORT_DIPNAME( 0x2000, 0x0000, DEF_STR( Flip_Screen ) )
  218.     PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
  219.     PORT_DIPSETTING(      0x2000, DEF_STR( On ) )
  220.     PORT_DIPNAME( 0x4000, 0x4000, "Control Panel" )
  221.     PORT_DIPSETTING(      0x4000, "Standard" )
  222.     PORT_DIPSETTING(      0x0000, "Original" )
  223.     PORT_DIPNAME( 0x8000, 0x0000, "Country" )
  224.     PORT_DIPSETTING(      0x0000, "Domestic" )
  225.     PORT_DIPSETTING(      0x8000, "Overseas" )
  226. INPUT_PORTS_END
  227.  
  228.  
  229.  
  230. static struct GfxLayout tail2nos_charlayout =
  231. {
  232.     8,8,
  233.     RGN_FRAC(1,1),
  234.     4,
  235.     { 0, 1, 2, 3 },
  236.     { 1*4, 0*4, 3*4, 2*4, 5*4, 4*4, 7*4, 6*4 },
  237.     { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 },
  238.     32*8
  239. };
  240.  
  241. static struct GfxLayout tail2nos_spritelayout =
  242. {
  243.     16,32,
  244.     RGN_FRAC(1,2),
  245.     4,
  246.     { 0, 1, 2, 3 },
  247.     { 1*4, 0*4, 3*4, 2*4, RGN_FRAC(1,2)+1*4, RGN_FRAC(1,2)+0*4, RGN_FRAC(1,2)+3*4, RGN_FRAC(1,2)+2*4,
  248.             5*4, 4*4, 7*4, 6*4, RGN_FRAC(1,2)+5*4, RGN_FRAC(1,2)+4*4, RGN_FRAC(1,2)+7*4, RGN_FRAC(1,2)+6*4 },
  249.     { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32,
  250.             8*32, 9*32, 10*32, 11*32, 12*32, 13*32, 14*32, 15*32,
  251.             16*32, 17*32, 18*32, 19*32, 20*32, 21*32, 22*32, 23*32,
  252.             24*32, 25*32, 26*32, 27*32, 28*32, 29*32, 30*32, 31*32 },
  253.     128*8
  254. };
  255.  
  256. static struct GfxDecodeInfo tail2nos_gfxdecodeinfo[] =
  257. {
  258.     { REGION_GFX1, 0, &tail2nos_charlayout,   0, 128 },
  259.     { REGION_GFX2, 0, &tail2nos_spritelayout, 0, 128 },
  260.     { -1 } /* end of array */
  261. };
  262.  
  263.  
  264.  
  265. static void irqhandler(int irq)
  266. {
  267.     cpu_set_irq_line(1,0,irq ? ASSERT_LINE : CLEAR_LINE);
  268. }
  269.  
  270. static struct YM2608interface ym2608_interface =
  271. {
  272.     1,
  273.     8000000,    /* 8 MHz??? */
  274.     { 25 },
  275.     { 0 },
  276.     { 0 },
  277.     { 0 },
  278.     { sound_bankswitch_w },
  279.     { irqhandler },
  280.     { REGION_SOUND1 },
  281.     { YM3012_VOL(50,MIXER_PAN_LEFT,50,MIXER_PAN_RIGHT) }
  282. };
  283.  
  284.  
  285.  
  286. static struct MachineDriver machine_driver_tail2nos =
  287. {
  288.     /* basic machine hardware */
  289.     {
  290.         {
  291.             CPU_M68000,
  292.             20000000/2,    /* 10 MHz (?) */
  293.             readmem,writemem,0,0,
  294.             m68_level6_irq,1
  295.         },
  296.         {
  297.             CPU_Z80 | CPU_AUDIO_CPU,
  298.             8000000/2,    /* 4 Mhz ??? */
  299.             sound_readmem,sound_writemem,sound_readport,sound_writeport,
  300.             ignore_interrupt,0    /* NMIs are triggered by the main CPU */
  301.                                 /* IRQs are triggered by the YM2608 */
  302.         }
  303.     },
  304.     60, DEFAULT_60HZ_VBLANK_DURATION,       /* frames per second, vblank duration */
  305.     1,    /* 1 CPU slice per frame - interleaving is forced when a sound command is written */
  306.     tail2nos_init_machine,
  307.  
  308.     /* video hardware */
  309.     64*8, 32*8, { 0*8, 40*8-1, 1*8, 31*8-1 },
  310.     tail2nos_gfxdecodeinfo,
  311.     2048, 2048,
  312.     0,
  313.  
  314.     VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE,
  315.     0,
  316.     tail2nos_vh_start,
  317.     tail2nos_vh_stop,
  318.     tail2nos_vh_screenrefresh,
  319.  
  320.     /* sound hardware */
  321.     SOUND_SUPPORTS_STEREO,0,0,0,
  322.     {
  323.         {
  324.             SOUND_YM2608,
  325.             &ym2608_interface,
  326.         }
  327.     }
  328. };
  329.  
  330.  
  331.  
  332. ROM_START( tail2nos )
  333.     ROM_REGION( 0x40000, REGION_CPU1 )    /* 68000 code */
  334.     ROM_LOAD_EVEN( "v4",           0x00000, 0x10000, 0x1d4240c2 )
  335.     ROM_LOAD_ODD ( "v7",           0x00000, 0x10000, 0x0fb70066 )
  336.     ROM_LOAD_EVEN( "v3",           0x20000, 0x10000, 0xe2e0abad )
  337.     ROM_LOAD_ODD ( "v6",           0x20000, 0x10000, 0x069817a7 )
  338.  
  339.     ROM_REGION( 0x80000, REGION_USER1 )
  340.     /* extra ROM mapped at 200000 */
  341.     ROM_LOAD_WIDE_SWAP( "a23",     0x00000, 0x80000, 0xd851cf04 )
  342.  
  343.     ROM_REGION( 0x20000, REGION_USER2 )
  344.     /* extra ROM mapped at 2c0000 */
  345.     ROM_LOAD_EVEN( "v5",           0x00000, 0x10000, 0xa9fe15a1 )
  346.     ROM_LOAD_ODD ( "v8",           0x00000, 0x10000, 0x4fb6a43e )
  347.  
  348.     ROM_REGION( 0x20000, REGION_CPU2 )    /* 64k for the audio CPU + banks */
  349.     ROM_LOAD( "v2",           0x00000, 0x08000, 0x920d8920 )
  350.     ROM_LOAD( "v1",           0x10000, 0x10000, 0xbf35c1a4 )
  351.  
  352.     ROM_REGION( 0x100000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  353.     ROM_LOAD( "a24",          0x00000, 0x80000, 0xb1e9de43 )
  354.     ROM_LOAD( "o1s",          0x80000, 0x40000, 0xe27a8eb4 )
  355.  
  356.     ROM_REGION( 0x080000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  357.     ROM_LOAD( "oj1",          0x000000, 0x40000, 0x39c36b35 )
  358.     ROM_LOAD( "oj2",          0x040000, 0x40000, 0x77ccaea2 )
  359.  
  360.     ROM_REGION( 0x20000, REGION_GFX3 )    /* gfx data for the 051316 */
  361.     /* RAM, not ROM - handled at run time */
  362.  
  363.     ROM_REGION( 0x20000, REGION_SOUND1 ) /* sound samples */
  364.     ROM_LOAD( "osb",          0x00000, 0x20000, 0xd49ab2f5 )
  365. ROM_END
  366.  
  367.  
  368.  
  369. /* note: this one has a 2608, not a 2610 */
  370. GAMEX( 1989, tail2nos, 0, tail2nos, tail2nos, 0, ROT90, "V-System Co.", "Tail to Nose - Great Championship", GAME_NO_COCKTAIL )
  371.